package com.dnjn.happiness.score.amqp;


import com.dnjn.happiness.common.amqp.AmqpConst;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class ScoreAmqpConfig {


    @Bean
    public Queue happyQueue() {
        return new Queue(AmqpConst.SCORE_QUEUE_NAME, true);
    }

    @Bean
    public DirectExchange happyDirectExchange() {
        return new DirectExchange(AmqpConst.SCORE_EXCHANGE_NAME, true, false);
    }

    @Bean
    public Binding happyBindingExchange() {

        return BindingBuilder.bind(happyQueue()).to(happyDirectExchange()).with(AmqpConst.SCORE_ROUTING_KEY);
    }

}